package com.fulin.security;

import java.security.NoSuchAlgorithmException;
import java.security.PublicKey;

import com.alibaba.druid.filter.config.ConfigTools;

/**
*
* @description 
* @auther fulin16@crnet.com.hk
* @since 2020年1月16日 上午10:37:38
*
*/
public class RSATest {
	public static void main(String[] args) throws Exception {
		String[] genKeyPair = ConfigTools.genKeyPair(1024);
		String pri = genKeyPair[0];
		String pub = genKeyPair[1];
		
		System.out.println(pub);
		System.out.println(pri);
		
		String text = "fulin_20161";
		System.out.println("加密后的密文 =>");
		String encrypt = ConfigTools.encrypt(pri, text);
		System.out.println(encrypt);
		
		System.out.println("解密后的明文 =>");
		String decrypt = ConfigTools.decrypt(pub, encrypt);
		System.out.println(decrypt);
		
	}
}
